package com.zm;

import com.zm.services.IAcountServices;
import config.SpringConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:Application.xml")
public class SpringWithJunit {
    //在Junit测试环境下使用SpringIoc容器
    @Resource(name = "AccountServicesImpl")
    private IAcountServices acountServices;

    //注入代理后的accountServices对象
    @Resource(name = "accountServicesProxy")
    private IAcountServices accountServicesProxy;


    @Test
    public void spring_junit(){
        acountServices.findAllAccount();
    }
    @Test
    public void tranMoney(){
    acountServices.tranMoney(2,1,100);
    }
    @Test
    public void tranWithProxy(){
    accountServicesProxy.tranMoney(1,2,50);

    }
}
